package com.txl.cn.lc

import com.alibaba.fastjson.JSON
import org.apache.spark.{SparkConf, SparkContext}
import org.apache.spark.rdd.RDD

/**
  * Created by txl on 2018/6/27.
  */
object OrderDemo2 {
  def main(args: Array[String]): Unit = {
    val conf = new SparkConf()
      .setAppName(this.getClass.getName)
      .setMaster("local[*]")
    val sc = new SparkContext(conf)
    val data = sc.textFile("data/json/test.json")
    val res= data.map(JSON.parseObject(_)).map(t => {
      val province = t.getString("province")
      val sums = t.getString("sums").toInt
      val rank = t.getString("rank").toInt
      Pro(province, sums, rank)
    })
    res.sortBy(t=>t).collect.foreach(println)
  }

}
